﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Public;
using BLL;


namespace QLNhanKhau
{
    public partial class frmChuyenDi : DevComponents.DotNetBar.Metro.MetroForm
    {
        public frmChuyenDi()
        {
            InitializeComponent();
        }

        private void btnThoat_Click(object sender, EventArgs e)
        {
            DialogResult result = MessageBox.Show("Thoát không lưu", "Thoát", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
            if (result == DialogResult.Yes)
            {
                this.MdiParent = null;
                this.Dispose();

            }
        }

        private void btnTimSHKcu_Click(object sender, EventArgs e)
        {
            int MaSHK = int.Parse(txtMaSHK.Text);
            List<NhanKhauPublic> list_nk = NhanKhauBLL.LoadNhanKhauByMaSHK(MaSHK);

            if (list_nk.Count == 0)
            {
                txtDuong.Text = txtAp.Text = txtSoNha.Text = txtChuHo.Text = "";

                dgvNhanKhauDi.DataSource = null;
                groupBox1.Enabled = false;
                groupBox2.Enabled = false;
                MessageBox.Show("Không tìm thấy!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            groupBox1.Enabled = true;
            groupBox2.Enabled = true;
            txtChuHo.Text = list_nk.Find(item => item.QuanHe == "Chủ hộ").HoTen;
            //txtChuHo.Text = list_nk.Where(item => item.QuanHe == "Chủ hộ").FirstOrDefault().HoTen;

            dgvNhanKhauDi.DataSource = list_nk;
            dgvNhanKhauDi.Columns[0].Visible = false;

            dgvNhanKhauDi.Columns[2].Visible = false;

            dgvNhanKhauDi.Columns[4].Visible = false;
            dgvNhanKhauDi.Columns[5].Visible = false;
            dgvNhanKhauDi.Columns[6].Visible = false;
            dgvNhanKhauDi.Columns[7].Visible = false;
            dgvNhanKhauDi.Columns[8].Visible = false;

            dgvNhanKhauDi.Columns[10].Visible = false;
            dgvNhanKhauDi.Columns[11].Visible = false;
            dgvNhanKhauDi.Columns[12].Visible = false;
            dgvNhanKhauDi.Columns[13].Visible = false;
            dgvNhanKhauDi.Columns[14].Visible = false;
            dgvNhanKhauDi.Columns[15].Visible = false;
            dgvNhanKhauDi.Columns[16].Visible = false;

            SoHoKhauPublic shk = SoHoKhauBLL.LoadSoHoKhauByMaSHK(MaSHK);

            txtDuong.Text = shk.Duong;
            txtAp.Text = "" + shk.KhuPho + "";
            txtSoNha.Text = shk.SoNha;
        }

        private void btnTimSHKMoi_Click(object sender, EventArgs e)
        {
            int MaSHK = int.Parse(txtMaSHK.Text);
            List<NhanKhauPublic> list_nkmoi = NhanKhauBLL.LoadNhanKhauByMaSHK(MaSHK);

            if (list_nkmoi.Count == 0)
            {
                txtDuong.Text = txtAp.Text = txtSoNha.Text = txtChuHo.Text = "";

                dgvNhanKhauDen.DataSource = null;
                groupBox1.Enabled = false;
                groupBox2.Enabled = false;
                MessageBox.Show("Không tìm thấy!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            groupBox1.Enabled = true;
            groupBox2.Enabled = true;
            txtChuHoMoi.Text = list_nkmoi.Find(item => item.QuanHe == "Chủ hộ").HoTen;
            //txtChuHo.Text = list_nk.Where(item => item.QuanHe == "Chủ hộ").FirstOrDefault().HoTen;

            dgvNhanKhauDen.DataSource = list_nkmoi;
            dgvNhanKhauDen.Columns[0].Visible = false;

            dgvNhanKhauDen.Columns[2].Visible = false;

            dgvNhanKhauDen.Columns[4].Visible = false;
            dgvNhanKhauDen.Columns[5].Visible = false;
            dgvNhanKhauDen.Columns[6].Visible = false;
            dgvNhanKhauDen.Columns[7].Visible = false;
            dgvNhanKhauDen.Columns[8].Visible = false;

            dgvNhanKhauDen.Columns[10].Visible = false;
            dgvNhanKhauDen.Columns[11].Visible = false;
            dgvNhanKhauDen.Columns[12].Visible = false;
            dgvNhanKhauDen.Columns[13].Visible = false;
            dgvNhanKhauDen.Columns[14].Visible = false;
            dgvNhanKhauDen.Columns[15].Visible = false;
            dgvNhanKhauDen.Columns[16].Visible = false;

            SoHoKhauPublic shk = SoHoKhauBLL.LoadSoHoKhauByMaSHK(MaSHK);

            txtDuongMoi.Text = shk.Duong;
            txtApMoi.Text = "" + shk.KhuPho + "";
            txtSoNhaMoi.Text = shk.SoNha;
        }

        private void btnTimSHKcu_Click_1(object sender, EventArgs e)
        {

        }

        private void panel1_Paint(object sender, PaintEventArgs e)
        {

        }

        private void dgvNhanKhauDen_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {

        }

        private void btnTimSHKMoi_Click_1(object sender, EventArgs e)
        {

        }

        private void txtChuHoMoi_TextChanged(object sender, EventArgs e)
        {

        }

        private void buttonX2_Click(object sender, EventArgs e)
        {

        }

        private void groupBox1_Enter(object sender, EventArgs e)
        {

        }

        private void btnThoat_Click_1(object sender, EventArgs e)
        {

        }

        private void btnLuu_Click(object sender, EventArgs e)
        {

        }

        private void groupBox2_Enter(object sender, EventArgs e)
        {

        }

        private void labelX3_Click(object sender, EventArgs e)
        {

        }

        private void txtSoNhaMoi_TextChanged(object sender, EventArgs e)
        {

        }

        private void txtDuongMoi_TextChanged(object sender, EventArgs e)
        {

        }

        private void txtApMoi_TextChanged(object sender, EventArgs e)
        {

        }

        private void labelX4_Click(object sender, EventArgs e)
        {

        }

        private void labelX5_Click(object sender, EventArgs e)
        {

        }

        private void labelX6_Click(object sender, EventArgs e)
        {

        }

        private void labelX2_Click(object sender, EventArgs e)
        {

        }

        private void textBoxX2_TextChanged(object sender, EventArgs e)
        {

        }

        private void buttonX1_Click(object sender, EventArgs e)
        {

        }

        private void txtChuHo_TextChanged(object sender, EventArgs e)
        {

        }

        private void labelX17_Click(object sender, EventArgs e)
        {

        }

        private void txtSoNha_TextChanged(object sender, EventArgs e)
        {

        }

        private void txtDuong_TextChanged(object sender, EventArgs e)
        {

        }

        private void txtAp_TextChanged(object sender, EventArgs e)
        {

        }

        private void labelX16_Click(object sender, EventArgs e)
        {

        }

        private void labelX15_Click(object sender, EventArgs e)
        {

        }

        private void labelX14_Click(object sender, EventArgs e)
        {

        }

        private void dgvNhanKhauDi_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {

        }

        private void labelX1_Click(object sender, EventArgs e)
        {

        }

        private void txtMaSHK_TextChanged(object sender, EventArgs e)
        {

        }

        private void tableLayoutPanel1_Paint(object sender, PaintEventArgs e)
        {

        }

        private void panel2_Paint(object sender, PaintEventArgs e)
        {

        }

        private void pictureBox1_Click(object sender, EventArgs e)
        {

        }

        private void label1_Click(object sender, EventArgs e)
        {

        }
    }
}
